<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>新增/编辑书</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link href="${ctx}/css/IFS.css" rel="stylesheet" type="text/css" />
	<script src="${ctx}/js/boot.js" type="text/javascript"></script>
	<style type="text/css">
	html, body {
		font-size:12px;padding:0;margin:0;border:0;height:100%;overflow:hidden;
	}
    </style>
</head>
<body>   
	 <form id="form1" method="post">
        <input name="bookId" class="mini-hidden" value="${pjsBook.bookId}"  />
        <input name="readId" class="mini-hidden" value="${pjsBookRead.readId}"  />
        <div style="padding-left:11px;padding-bottom:5px;">
           <!-- <table style="table-layout:fixed;"> -->
            <table border="0" cellpadding="1" cellspacing="2" style="width:100%;table-layout:fixed;padding-top:5px;padding-left:15px;padding-bottom:5px;">
                <tr>
                    <td style="width:70px;">书名：</td>
                    <td style="width:200px;">    
                        <input name="bookName" value="${pjsBook.bookName}" class="mini-textbox"  allowInput="false" enabled="false"/>
                    </td>
                    <td style="width:70px;">阅读人：</td>
                    <td style="width:200px;">    
                        <input name="reader" class="mini-textbox" required="true"  value="liangcz" emptyText="请输入阅读人"/>
                    </td>
                </tr>
				<tr>
                	<td style="width:70px;">开始日期：</td>
	   				<td style="width:150px;"> 
	        			<input  id="readBegin" name="readBegin" class="mini-datepicker" format="yyyy-MM-dd" value="${pjsBookRead.readBegin}"
	        					 showTime="false" showOkButton="true" showClearButton="false" /> 
	        		</td>
	        		<td style="width:70px;">结束日期：</td>
	   				<td style="width:150px;"> 
	        			<input  id="readEnd" name="readEnd" class="mini-datepicker" format="yyyy-MM-dd" value="${pjsBookRead.readEnd}"
	        					 showTime="false" showOkButton="true" showClearButton="false" /> 
	        		</td>
				</tr>
                <tr>
                    <td style="width:120px;">费时(小时)：</td>
                    <td style="width:150px;">    
                        <input name="takeTime" class="mini-textbox"  emptyText="请输入花费时间(小时)" value="${pjsBookRead.takeTime}"/>
                    </td>
                </tr>  
                 <tr>
				<td  colspan="2">    
                        <input style="width:575px;height:250px;" name="feelRead" class="mini-textarea" required="false" value="${pjsBookRead.feelRead}" emptyText="--------请输入读后感1--------"/>
                 </td>		
                 </tr> 	
            </table>
        </div>
        <div style="text-align:center;padding:10px;">               
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>       
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
        </div>        
    </form>
   
	<script type="text/javascript">
		mini.parse();
	
	    var form = new mini.Form("form1");
		
	    function SaveData() {
	        form.validate();
	        if (form.isValid() == false) return;
	        var o = form.getData();
	        $.ajax({
	            url: "${ctx}/pjs/service/ReadBookService/saveReadBook.do",
				type: 'post',
	            data: o,
	            cache: false,
	            dataType : "json",
	            success : function(data) { 	
					var o = mini.decode(data);
			        if(o.success == true){
			        	// alert("保存成功");
			        	CloseWindow("save");
			        }else{
			        	alert(o.message);
			        }
				} 
	        });
	    }
	
	    ////////////////////
	    //标准方法接口定义
	    function SetData(data) {
	        if (data.action == "edit") {
	        	mini.getByName("bookId").disable();
	            //跨页面传递的数据对象，克隆后才可以安全使用
	            data = mini.clone(data);
	            $.ajax({
	                url: "${ctx}/pjs/service/BookService/inquiryBook.do?bookId=" + data.bookId,
	                cache: false,
	                success: function (text) {
	                    var o = mini.decode(text);
	                    form.setData(o);
	                    form.setChanged(false);
	                }
	            });
	        }
	    }
	
	    function GetData() {
	        var o = form.getData();
	        return o;
	    }
	    function CloseWindow(action) {            
	        if (action == "close" && form.isChanged()) {
	            if (confirm("数据被修改了，是否先保存？")) {
	                return false;
	            }
	        }
	        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
	        else window.close();            
	    }
	    function onOk(e) {
	        SaveData();
	    }
	    function onCancel(e) {
	        CloseWindow("cancel");
	    }

    </script>

</body>
</html>
